package cn.yangliu.entity;

import lombok.Data;

import javax.persistence.Entity;
import javax.persistence.Table;
import javax.persistence.Transient;

/**
 * @author 问道于盲
 * @date 2021-10-03
 */
@Entity
@Table(name = "t_cache")
@Data
public class Cache extends AbstractEntity{

    /**
     * key
     */
    private String key;

    /**
     * val
     */
    private String val;

    /**
     * 放入缓存
     *
     * @param key key
     * @param val val
     */
    public void put(String key, String val){
        this.key = key;
        this.val = val;
    }

    /**
     * 值转换为long
     *
     * @return long
     */
    @Transient
    public long getLong(){
        return Long.parseLong(val);
    }
}
